import axios from "axios";
import store from "../store";
const baseURL = " http://localhost:3000/";
const request = axios.create({
    baseURL,
    timeout: 5000,
})

request.interceptors.request.use(config => {
    // 在发送请求前要做的事儿
    let cookie = store.state.user.user.cookie
    // console.log(cookie, 123)
    if (config.method?.toLocaleLowerCase() == "get") {
        config.params = { ...config.params, cookie };
    } else {
        config.data = { ...config.data, cookie };
    }
    // config.headers["Authorization"] = cookie
    // console.log(config,"config--11")
    return config
}, err => {
    // 在请求错误时要做的事儿

    // 该返回的数据则是axios.catch(err)中接收的数据
    return Promise.reject(err)
})

export default request;